package me.zhanshi123.vipstorage.command;

import me.zhanshi123.vipstorage.command.subcommand.ClaimCommand;
import me.zhanshi123.vipstorage.command.subcommand.ListCommand;
import me.zhanshi123.vipstorage.command.subcommand.StoreCommand;
import org.bukkit.Bukkit;

import java.util.HashSet;
import java.util.Set;

public class Commands {
    private static Commands instance = null;

    public static Commands getInstance() {
        return instance;
    }


    private Set<SubCommand> commands = new HashSet<>();

    public Commands(String name) {
        Bukkit.getPluginCommand(name).setExecutor(new CommandsExecutor());
        instance = this;
        commands.add(new ListCommand());
        commands.add(new StoreCommand());
        commands.add(new ClaimCommand());
    }

    public SubCommand getSubCommand(String cmd) {
        SubCommand fact = null;
        for (SubCommand command : commands) {
            if (command.getName().equalsIgnoreCase(cmd)) {
                fact = command;
                break;
            }
        }
        return fact;
    }
}
